package com.yupi.yuapiclientsdk;

import com.yupi.yuapiclientsdk.client.YuApiClient;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

//通过 @Configuration 注解，将该类标记为一个配置类
@Configuration
//通过 @ConfigurationProperties 注解，使用该注解来绑定配置文件中的属性值到当前类中的属性上
@ConfigurationProperties("yuapi.client")
@Data
//通过 @ComponentScan 注解用于自动扫描组件，使得 Spring 能够自动注册相应的Bean
@ComponentScan
public class YuApiClientConfig {

    private String accessKey;
    private String secretKey;

    @Bean
    public YuApiClient yuApiClient() {
        //使用 ak 和 sk 创建一个YuApiClient实例
        return new YuApiClient(accessKey, secretKey);
    }
}
